<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<view class="header-section">
			<view class="flex justify-between" style="align-items: center;">
				<view class="flex align-center">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>
					</view>
					<view class="user-avatar">
						<!-- 
						<image @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
						</image> -->
						<!-- 	<image @click="handleToAvatar" src="@/static/morentx.jpg" class="cu-avatar xl round"
							mode="widthFix">
						</image> -->
					</view>
					<view v-if="!name" @click="handleToLogin" class="login-tip">
						点击登录
					</view>
					<view v-if="name" @click="handleToInfo" class="user-info">
						<view class="u_title">
							{{ name }}
						</view>
						<view class="" v-if="phoneNumber">
							{{phoneNumber}}
						</view>
					</view>
				</view>
				<view @click="handleToInfo" class="flex align-center">
					<text>个人信息</text>
					<view class="iconfont icon-right"></view>
				</view>
			</view>
		</view>
		<view class="main">
			<view class="user-vip" style="padding-bottom: 130rpx;">

				<view class="usual-tools-box bg-white mt20">
					<view class="usual-tools-header row lg bold">
						常用工具
					</view>
					<view class="menu-list">
						<view class="list-cell list-cell-arrow" @click="handleToEditInfo">
							<view class="menu-item-box">
								<view class="iconfont icon-user menu-icon"></view>
								<view>编辑资料</view>
							</view>
						</view>
						<view class="list-cell list-cell-arrow" @click="handleHelp">
							<view class="menu-item-box">
								<view class="iconfont icon-help menu-icon"></view>
								<view>常见问题</view>
							</view>
						</view>
						<view class="list-cell list-cell-arrow" @click="handleAbout">
							<view class="menu-item-box">
								<view class="iconfont icon-aixin menu-icon"></view>
								<view>关于我们</view>
							</view>
						</view>
						<view class="list-cell list-cell-arrow" @click="handleToSetting">
							<view class="menu-item-box">
								<view class="iconfont icon-setting menu-icon"></view>
								<view>应用设置</view>
							</view>
						</view>
					</view>

				</view>



			</view>
		</view>

	</view>
</template>

<script>
	import priceFormat from '@/components/price-format/price-format.vue';
	import {
		signInApi,
		getTotalPointsApi,
		getTeamUserNumApi,
		getPhoneApi
	} from '@/api/index.js';
	import {
		getInfo
	} from '@/api/login'
	export default {
		data() {
			return {
				name: this.$store.state.user.name,
				able_withdrawal: 0,
				history_earnings: 0,
				today_earnings: 0,
				signIn: false, //今日是否已签到
				teamUser: 0, //团队人数
				phoneNumber: '',
				invitationCode: null,
			}
		},
		components: {
			priceFormat
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			}
		},
		onShow() {
			console.log('页面显示');
			this.getUserInfo();
		},
		methods: {

			// 获取用户信息
			getUserInfo() {
				getInfo().then(res => {
					console.log(res.user, '获取用户信息');
					this.invitationCode = res.user.invitationCode;
					this.signIn = res.user.signIn || false;
				})
			},
			toTeam() {
				this.$tab.navigateTo('/pages/mine/team/team')
			},
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				this.$tab.navigateTo('/pages/mine/info/edit')
			},
			handleToSetting() {
				this.$tab.navigateTo('/pages/mine/setting/index')
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/mine/help/index')
			},
			handleAbout() {
				this.$tab.navigateTo('/pages/mine/about/index')
			},
			handleJiaoLiuQun() {
				this.$modal.showToast('QQ群：①133713780(满)、②146013835(满)、③189091635')
			},
			handleBuilding() {
				this.$modal.showToast('模块建设中~')
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f6f7;
	}

	.mine-container {
		width: 100%;
		height: 100%;


		.header-section {
			padding: 15px 15px 45px 15px;
			background-color: #0081ff;
			// background-image: url('@/static/images/mine-bg.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
			color: white;
			height: 105px;

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				width: 57px !important;
				height: 57px !important;
				max-height: 57px !important;
				max-width: 57px !important;
				// border: 2px solid #eaeaea;

				.icon {
					font-size: 40px;
				}
			}

			.user-info {
				margin-left: 15px;

				.u_title {
					font-size: 18px;
					line-height: 30px;
					font-weight: 600;
				}
			}
		}

		.content-section {
			position: relative;
			top: -50px;

			.mine-actions {
				margin: 15px 15px;
				padding: 20px 0px;
				border-radius: 8px;
				background-color: white;

				.action-item {
					.icon {
						font-size: 28px;
					}

					.text {
						display: block;
						font-size: 13px;
						margin: 8px 0px;
					}
				}
			}
		}
	}

	.user-avatar {
		width: 110rpx;
		height: 110rpx;
		position: relative;

		.avatar-tag {
			position: absolute;
			bottom: -16rpx;
			left: 15rpx;
			width: 80rpx;
			background-color: #F79C0C;
			border: 1rpx solid #FFFFFF;
			border-radius: 100rpx;
			font-size: 26rpx;
			// line-height: 30rpx;
			text-align: center;
		}
	}

	.main {
		padding: 0 20rpx;
		margin-top: -60rpx;

		.user-vip {
			.user-assets-box {
				background-color: #fff;
				border-radius: 20rpx;
				padding: 10rpx 20rpx 22rpx;
				background: linear-gradient(90deg, #f1fbfb 0%, #9bcffe 100%);

				.user-assets-header {
					border-bottom: 1rpx dashed #8F430E;
					padding-bottom: 4rpx;

					.primary-btn {
						text-align: center;
						height: 54rpx;
						line-height: 54rpx;
						border-radius: 120rpx;
						width: 144rpx;
						background: linear-gradient(180deg, #FF3067 0%, #FF2C3C 100%);
					}
				}

				.user-assets-content {
					margin-top: 30rpx;

					.user-item {
						flex: 1;
						position: relative;

						.user-assets-name {
							// border: 1rpx solid #000;
							width: 100%;
							text-align: center;
							align-self: flex-start;
							justify-content: center;
						}

						.assets {
							margin-top: 14rpx;
							text-align: center;
							align-self: flex-start;
							// border: 1rpx solid #000;
							width: 100%;
						}

						// &:last-of-type .assets {
						//     align-self: center;
						//     margin-top: 14rpx;
						//     text-align: left;
						// }
					}
				}
			}

			.fans-msg-box {
				border-radius: 10rpx;
				line-height: 42rpx;

				.my-fans {
					width: 50%;
					height: 120rpx;
				}

				.line {
					width: 3rpx;
					height: 60rpx;
					background-color: #E5E5E5;
				}

				.invite-fans {
					width: 50%;
					height: 120rpx;
				}
			}

			.my-invite-box {
				padding: 26rpx 0 57rpx;
				border-radius: 10rpx;

				.invite-copy-btn {
					line-height: 30rpx;
					padding: 10rpx;
					background: linear-gradient(90deg, #FEE4B4 0%, #FBCB96 100%);
					color: #8F430E;
					border-radius: 4rpx;
				}

				.my-promote-banner {
					margin-top: 30rpx;
					height: 148rpx;
					width: 542rpx;
					border-radius: 10rpx;
				}
			}

			.usual-tools-box {
				border-radius: 10rpx;
				padding: 25rpx;

				.usual-tools-header {
					color: #000;
					height: 70rpx;
					// line-height: 44rpx;
					border-bottom: 1px solid #E5E5E5;
				}

				.usual-content {
					width: 625rpx;
					padding: 40rpx 0;
					// border: 1rpx solid #000;

					.usual-item {
						width: 25%;
						// border: 1rpx solid #000;

						.usual-item-img {
							width: 64rpx;
							height: 64rpx;
							flex: none;
						}

					}
				}
			}
		}

		.user-apply-box {
			.user-apply-vip {
				background-color: white;
				padding: 40rpx 0 0rpx;
				border-radius: 20rpx;

				.title {
					line-height: 30rpx;
					font-weight: bold;
				}

				.explain {
					margin-top: 20rpx;

					image {
						width: 24rpx;
						height: 24rpx;
						flex: none;
					}

					span {
						font-size: 20rpx;
						line-height: 30rpx;
					}
				}

				.vip-form {
					width: 100%;
					flex: 1;
					margin-top: 60rpx;

					.form-item {
						padding: 24rpx 0 24rpx 30rpx;
						border: 1rpx solid #000;
						margin: 0 34rpx 30rpx;

						.label {
							width: 150rpx;
							line-height: 30rpx;
						}

						input {
							flex: 1;
							font-size: 30rpx;
							margin-left: 10rpx;
							line-height: 30rpx;
							padding-right: 20rpx;
						}
					}
				}
			}

			.apply-btn {
				line-height: 30rpx;
				height: 82rpx;
			}
		}

		.user-result-box {
			.user-result {
				background-color: white;
				padding: 36rpx 14rpx 50rpx;
				border-radius: 20rpx;

				.user-result-header {
					.title {
						line-height: 30rpx;
						font-weight: bold;
					}

				}

				.user-result-content {
					padding: 60rpx 0 22rpx;
					/* margin: 0 8px; */
					width: 100%;
					border-bottom: 1rpx solid #8F430E;

					.apply-result-img {
						width: 100rpx;
						height: 100rpx;
					}
				}

				.user-result-info {
					margin-top: 42rpx;
					width: 100%;

					.info-item {
						margin-left: 60rpx;
						margin-bottom: 28rpx;
						line-height: 30rpx;

						.label {
							width: 140rpx;
						}
					}
				}
			}

			.apply-btn {
				line-height: 30rpx;
				height: 82rpx;
			}

			.bg-gray {
				background-color: #CCCCCC;
			}
		}
	}

	.sign {
		text-align: center;
		height: 54rpx;
		line-height: 54rpx;
		border-radius: 120rpx;
		width: 144rpx;
		color: #ff2e50;
		background: #fff;

		text {
			width: 100%;
		}
	}
</style>